# -*- coding: utf-8 -*-
import time
from selenium import webdriver
import unittest
import xlrd
from Page.loginPage import loginPage
from publicModule.login import login
from Page.customerPage import customerPage
from publicModule.customer import customer
from Page.informaintenancePage import informaintenancePage
from publicModule.informaintenance import informaintenance
from Page.noscanningPage import noscanningPage
from publicModule.noscanning import noscanning
class Test_Customer(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        print('开始测试')
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("http://10.22.26.34:8080/fwd/indexlis.jsp")
        time.sleep(2)

        self.loginPage = loginPage(self.driver)
        self.login = login(self.driver)
        self.customerPage=customerPage(self.driver)
        self.customer=customer(self.driver)
        self.informaintenancePage = informaintenancePage(self.driver)
        self.informaintenance = informaintenance(self.driver)
        self.noscanningPage = noscanningPage(self.driver)
        self.noscanning = noscanning(self.driver)
    # @classmethod
    # def tearDownClass(self):
    #     print('结束测试')
    #     self.driver.quit()
    def test01(self):
        print('test01')
        filename='..//TestData//loginData.xlsx'
        excel_open=xlrd.open_workbook(filename)
        table=excel_open.sheet_by_name('Sheet1')
        rows=table.nrows
        for i in range(2,rows):
            row_content=table.row_values(i)
            username=row_content[0]
            password=row_content[1]
            orgcode=row_content[2]
            login.login(self,username,password,orgcode)
    def test02(self):
        # 团险业务
        customer.GrpInsurance(self)
        time.sleep(1)
        # 询报价管理
        customer.CustomerManager(self)
        time.sleep(1)
        # 一般询价录入
        customer.CustomerMaintanence(self)
        time.sleep(1)
    def test03(self):
        filename = '..//TestData//customerAdd.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            CustomerName = row_content[0]
            IDType = row_content[1]
            IDNo = row_content[2]
            GrpNature = row_content[3]
            BusiCategory = row_content[4]
            SumNumPeople = int(row_content[5])
            SaleChannel = row_content[6]
            ProvinceName = row_content[7]
            CityName = row_content[8]
            CountyName = row_content[9]
            DetailAddress = row_content[10]
            customer.CustomerIfm(self,CustomerName,IDType,IDNo,GrpNature,BusiCategory,SumNumPeople,SaleChannel,
                    ProvinceName,CityName,CountyName,DetailAddress)
    def test04(self):
        filename = '..//TestData//customerAdd.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            LinkMan = row_content[11]
            Mobile = row_content[12]
            Phone = row_content[13]
            Depart = row_content[14]
            Post = row_content[15]
            Email = row_content[16]
            customer.LinkManIfm(self,LinkMan,Mobile,Phone,Depart,Post,Email)
    def test05(self):
        filename = '..//TestData//customerAdd.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            ProdType = row_content[17]
            PremMode = row_content[18]
            ValDateType = row_content[19]
            RenewFlag = row_content[20]
            customer.InquiryApply(self,ProdType,PremMode,ValDateType,RenewFlag)
        customer.PlanInformation(self)
    def test06(self):
        filename = '..//TestData//test03Data.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(1, rows):
            row_content = table.row_values(i)
            PlanDesc = row_content[0]
            MinAge = int(row_content[1])
            MaxAge = int(row_content[2])
            AvgAge = int(row_content[3])
            NumPeople = int(row_content[4])
            MinSalary = int(row_content[5])
            MaxSalary = int(row_content[6])
            AvgSalary = int(row_content[7])
            OtherDesc = row_content[8]
            OccupType = row_content[13]
            OccupName = row_content[10]
            OccupMidTypeCode = row_content[11]
            OccupMidName = row_content[12]
            OccupCode = row_content[9]
            SocialInsuRate = row_content[14]
            MaleRate = row_content[15]
            FemaleRate = row_content[16]
            informaintenance.informaintenance1(self, PlanDesc, MinAge, MaxAge, AvgAge, NumPeople, MinSalary, MaxSalary,
                                              AvgSalary, OtherDesc,
                                              OccupType, OccupMidTypeCode, OccupCode,SocialInsuRate,MaleRate,FemaleRate)
        informaintenance.planDetailOpen(self)
    def test07(self):
        filename = '..//TestData//test04Data.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(1, rows):
            row_content = table.row_values(i)
            # Franchise = int(row_content[0])
            # RatePay = int(row_content[1])
            FixedAmnt = int(row_content[2])
            ExceptPrem = row_content[3]
            Remark = row_content[4]
            PlanCode = row_content[5]
            RiskCode = row_content[6]
            DutyCode = row_content[7]
            AmntType = row_content[8]
            ExceptPremType = row_content[9]
            informaintenance.informationDetail1(self, FixedAmnt, ExceptPrem, Remark, PlanCode, DutyCode, RiskCode,
                                               AmntType, ExceptPremType)
    def test08(self):
        filename = '..//TestData//customerAdd.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            btnAgentDetailGrid1 = row_content[21]
            PreCustomerNo = row_content[22]
            CommissionRate = row_content[23]
            customer.CommissionInformation(self,btnAgentDetailGrid1,PreCustomerNo,CommissionRate)




